<template>
    <view class="my-user-container">
        <!--头像昵称区域-->
        <view class="header-box">
            <image class="avatar" :src="userInfo.avatarUrl"></image>
            <text class="nickname">{{ userInfo.nickname }}</text>
        </view>
        <!--面板区域-->
        <view class="panel-list">
            <!--第一个面板区域-->
            <view class="panel">
                <view class="panel-body">
                    <view class="panel-item">
                        <text>0</text>
                        <text>收藏的店铺</text>
                    </view>
                    <view class="panel-item">
                        <text>0</text>
                        <text>收藏的商品</text>
                    </view>
                    <view class="panel-item">
                        <text>0</text>
                        <text>关注的商品</text>
                    </view>
                    <view class="panel-item">
                        <text>0</text>
                        <text>历史浏览</text>
                    </view>
                </view>
            </view>
            <!--第二个面板区域-->
            <view class="panel">
                <view class="panel-title">
                    <text>我的订单</text>
                </view>
                <view class="panel-body">
                    <view class="panel-item">
                        <image src="/static/order/receiving.png" class="icon"></image>
                        <text>待收货</text>
                    </view>
                    <view class="panel-item">
                        <image src="/static/order/payment.png" class="icon"></image>
                        <text>待付款</text>
                    </view>
                    <view class="panel-item">
                        <image src="/static/order/refund.png" class="icon"></image>
                        <text>退款/退货</text>
                    </view>
                    <view class="panel-item">
                        <image src="/static/order/all-order.png" class="icon"></image>
                        <text>全部订单</text>
                    </view>
                </view>
            </view>
            <!--第三个面板区域-->
            <view class="panel">
                <view class="panel-list-item">
                    <text>收货地址</text>
                    <uni-icons type="right"></uni-icons>
                </view>
                <view class="panel-list-item">
                    <text>联系客服</text>
                    <uni-icons type="right"></uni-icons>
                </view>
                <view class="panel-list-item exit">
                    <button type="primary" style="background-color: #ff93a7" @click="exitLogin">退出登录</button>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import {mapState,mapMutations} from "vuex"

    export default {
        computed: {
            ...mapState('user', ['userInfo'])
        },
        data() {
            return {};
        },
        methods: {
            ...mapMutations('user',['updateUserInfoObj','updateAddress','removeToken','updateToken']),
            async exitLogin() {
                await uni.showModal({
                    title: '温馨提示',
                    content: '您确定要退出登录吗？',
                    confirmColor:'#ff93a7',
                    success: (res) => {
                        if (res.confirm){
                            this.updateAddress({})
                            this.updateUserInfoObj({})
                            // this.removeToken()
                            this.updateToken('')
                        }
                    }
                })
            }
        },
    }
</script>

<style lang="scss">
    .my-user-container {
        width: 100%;
        background-color: #f8f8f8;

        // 头像昵称样式
        .header-box {
            height: 400rpx;
            background-color: #ff93a7;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;

            .avatar {
                height: 100px;
                width: 100px;
                border: 1px solid #FFFFFF;
                border-radius: 50%;
                box-shadow: 0 1px 5px #000000;
            }

            .nickname {
                font-size: 16px;
                //color: #FFFFFF;
                font-weight: bold;
                margin-top: 15px;
                background-image: -webkit-linear-gradient(left, #ff00cc, #ffcc00, #00ffcc, #ff0066);
                background-clip: text;
                -webkit-text-fill-color: transparent;
            }
        }

        // 面板样式
        .panel-list {
            padding: 0 10px;
            margin-top: -15px;

            .panel {
                background-color: #FFFFFF;
                border-radius: 3px;
                margin-bottom: 8px;

                .panel-title {
                    line-height: 45px;
                    padding-left: 10px;
                    font-size: 15px;
                    border-bottom: 1px solid #f4f4f4;
                }
                .panel-list-item {
                    display: flex;
                    justify-content: space-between;
                    padding: 0 10px;
                    line-height: 45px;
                }
                .exit {
                    padding: 8px 10px;
                    button {
                        width: 60%;
                    }
                }
                .panel-body {
                    display: flex;
                    justify-content: space-around;

                    .panel-item {
                        display: flex;
                        flex-direction: column;
                        justify-content: center;
                        align-items: center;
                        padding: 12px 0;
                        font-size: 14px;

                        .icon {
                            width: 35px;
                            height: 35px;
                        }
                    }
                }
            }
        }
    }
</style>
